package com.santoker.user.service.dto.vo.record;

import com.alibaba.fastjson.JSONObject;
import com.beust.jcommander.internal.Lists;
import com.santoker.user.service.util.HttpUtil;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;

@Data
public class TrainDataVo {


    public static void main(String[] args) throws IOException {
        List xTrain = Lists.newArrayList();
        List data = null;
        for (int i=0; i < 12; i++) {
            data = Lists.newLinkedList();
            data.add(i);
            data.add(3.176513);
            data.add(3.176513);
            xTrain.add(data);
        }
        List target = Lists.newArrayList();
        target.add(50);
        target.add(52);
        target.add(56);
        target.add(58);
        target.add(60);
        target.add(59);
        target.add(58);
        target.add(56);
        target.add(55);
        target.add(53);
        target.add(51);
        target.add(50);

        // 请求python接口，计算训练集取消
        String urlString = new StringBuffer()
                .append("http://39.103.170.204:8868/service?")
                .append("x_train=").append(xTrain).append("&")
                .append("target=").append(target).append("&")
                .append("x_test=").append(xTrain)
                .toString();
        String body = HttpUtil.doGet(urlString);
        System.out.println("body = "+body);
        if (StringUtils.isNotEmpty(body)) {
            List<BigDecimal> resultList = JSONObject.parseArray(body, BigDecimal.class);
            System.out.println("resultList = " + resultList);
        }
    }

}
